home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / include / image.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  96 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #ifndef    __GL_IMAGE_H__
  18. #define    __GL_IMAGE_H__
  19. /*
  20.  *    Defines for image files . . . .
  21.  *
  22.  *              Paul Haeberli - 1984
  23.  *      Look in /usr/people/4Dgifts/iristools/imgtools for example code!
  24.  *
  25.  */
  26.  
  27. #include <stdio.h>
  28.  
  29. #define IMAGIC     0732
  30.  
  31. /* colormap of images */
  32. #define CM_NORMAL        0    /* file contains rows of values which 
  33.                      * are either RGB values (zsize == 3) 
  34.                      * or greyramp values (zsize == 1) */
  35. #define CM_DITHERED        1
  36. #define CM_SCREEN        2    /* file contains data which is a screen
  37.                      * image; getrow returns buffer which 
  38.                      * can be displayed directly with 
  39.                      * writepixels */
  40. #define CM_COLORMAP        3    /* a colormap file */
  41.  
  42. #define TYPEMASK        0xff00
  43. #define BPPMASK            0x00ff
  44. #define ITYPE_VERBATIM        0x0000
  45. #define ITYPE_RLE        0x0100
  46. #define ISRLE(type)        (((type) & 0xff00) == ITYPE_RLE)
  47. #define ISVERBATIM(type)    (((type) & 0xff00) == ITYPE_VERBATIM)
  48. #define BPP(type)        ((type) & BPPMASK)
  49. #define RLE(bpp)        (ITYPE_RLE | (bpp))
  50. #define VERBATIM(bpp)        (ITYPE_VERBATIM | (bpp))
  51. #define    IBUFSIZE(pixels)    ((pixels+(pixels>>6))<<2)
  52. #define    RLE_NOP            0x00
  53.  
  54. #define    ierror(p)        (((p)->flags&_IOERR)!=0)
  55. #define    ifileno(p)        ((p)->file)
  56. #define    getpix(p)        (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p))
  57. #define putpix(p,x)        (--(p)->cnt>=0 \
  58.                     ? ((int)(*(p)->ptr++=(unsigned)(x))) \
  59.                     : iflsbuf(p,(unsigned)(x)))
  60.  
  61. typedef struct {
  62.     unsigned short    imagic;        /* stuff saved on disk . . */
  63.     unsigned short     type;
  64.     unsigned short     dim;
  65.     unsigned short     xsize;
  66.     unsigned short     ysize;
  67.     unsigned short     zsize;
  68.     unsigned long     min;
  69.     unsigned long     max;
  70.     unsigned long    wastebytes;    
  71.     char         name[80];
  72.     unsigned long    colormap;
  73.  
  74.     long         file;        /* stuff used in core only */
  75.     unsigned short     flags;
  76.     short        dorev;
  77.     short        x;
  78.     short        y;
  79.     short        z;
  80.     short        cnt;
  81.     unsigned short    *ptr;
  82.     unsigned short    *base;
  83.     unsigned short    *tmpbuf;
  84.     unsigned long    offset;
  85.     unsigned long    rleend;        /* for rle images */
  86.     unsigned long    *rowstart;    /* for rle images */
  87.     long        *rowsize;    /* for rle images */
  88. } IMAGE;
  89.  
  90. IMAGE *iopen();
  91. IMAGE *icreate();
  92. unsigned short *ibufalloc();
  93.  
  94. #define IMAGEDEF        /* for backwards compatibility */
  95. #endif    /* !__GL_IMAGE_H__ */
  96.